﻿using AutoMapper;
using MediatR;
using ProductionManagement.Application.Command.StrippingCommand;
using ProductionManagement.Domain.Dtos;
using ProductionManagement.Domain.ProductionDomain;
using ProductionManagement.Infrstructre.lnterface;

namespace ProductionManagement.Application.CommandHandler.StrippingCommandHandler
{
    public class StrippingWarhouseUpdCommandHandler : IRequestHandler<StrippingWarhouseUpdCommand, int>
    {

        IMapper mapper;
        IStrippingRepository sRep;

        public StrippingWarhouseUpdCommandHandler(IMapper mapper, IStrippingRepository sRep)
        {
            this.mapper = mapper;
            this.sRep = sRep;
        }


        public async Task<int> Handle(StrippingWarhouseUpdCommand request, CancellationToken cancellationToken)
        {
            var list = new Stripping
            {
                StrippingId = request.StrippingId,
                StripNumber = request.StripDocumentNumber,
                StripWState = request.StripWState,
                StripDocumentNumber = request.StripDocumentNumber,
                StripDate = request.StripDate,
                StripNumTotal = request.StripNumTotal,
                AddName=request.AddName,
                AddTime=request.AddTime,
                UpdName=request.UpdName,
                UpdTime=request.UpdTime,
                DelName=request.DelName,
                DelTime=request.DelTime,
                Office_Id=request.Office_Id,
                User_Id=request.User_Id
            };
            return await sRep.UpdAsync(list);
        }
    }
}
